import { Module } from '@nestjs/common';
import { TypegooseModule } from 'nestjs-typegoose';
import { User } from './models/user.model';
import { Category } from './models/category.model';
import { Book } from './models/book.model';
import { Order } from './models/order.model';
import { Car } from './models/car.model';

const models = TypegooseModule.forFeature([User, Category, Book, Car, Order]);

@Module({
  imports: [
    TypegooseModule.forRootAsync({
      useFactory() {
        return {
          uri: process.env.DB_PATH,
          useCreateIndex: true,
          useFindAndModify: false,
          useNewUrlParser: true,
          useUnifiedTopology: true,
        };
      },
    }),
    models,
  ],
  providers: [],
  exports: [models],
})
export class DbModule {}
